package Test;

import Roboter.Elektromagnet;
import Roboter.Hubservo;
import lejos.nxt.Button;
import lejos.nxt.ButtonListener;
import lejos.nxt.LCD;
import lejos.nxt.MotorPort;
import lejos.nxt.SensorConstants;
import lejos.nxt.SensorPort;
import lejos.nxt.Tools;

public class PotiTest {
	private static Elektromagnet mag;
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		SensorPort.S1.setTypeAndMode(SensorPort.SP_ANA,SensorConstants.MODE_RAW);
		SensorPort.S2.setTypeAndMode(SensorPort.SP_ANA,SensorConstants.MODE_RAW);
		SensorPort.S3.setTypeAndMode(SensorPort.SP_ANA,SensorConstants.MODE_RAW);
		mag = new Elektromagnet(); 
		
		Button.ESCAPE.addButtonListener(new ButtonListener() {
			
			@Override
			public void buttonReleased(Button arg0) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void buttonPressed(Button arg0) {
				System.exit(0);
			}
		});
		
		
		Button.ENTER.addButtonListener(new ButtonListener() {
			
			@Override
			public void buttonReleased(Button arg0) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void buttonPressed(Button arg0) {
				mag.schalten();
			}
		});
		
		Button.LEFT.addButtonListener(new ButtonListener() {
			
			@Override
			public void buttonReleased(Button arg0) {
				MotorPort.A.controlMotor(100, MotorPort.STOP);
			}
			
			@Override
			public void buttonPressed(Button arg0) {
				MotorPort.A.controlMotor(60, MotorPort.BACKWARD);
			}
		});
		
		Button.RIGHT.addButtonListener(new ButtonListener() {
			
			@Override
			public void buttonReleased(Button arg0) {
				MotorPort.A.controlMotor(100, MotorPort.STOP);
			}
			
			@Override
			public void buttonPressed(Button arg0) {
				MotorPort.A.controlMotor(60, MotorPort.FORWARD);
			}
		});
		
		Hubservo hub = new Hubservo();
		hub.auf();
		hub.stopp();
		
		while(true) {
			System.out.println("Linear: " + SensorPort.S1.readRawValue());
			System.out.println("Rotation: " + SensorPort.S2.readRawValue());
			System.out.println("Hub: " + SensorPort.S3.readRawValue());
			Tools.delay(1000);
			LCD.clear();
		}
	}

}
